package com.zhiyuan.audio;

public class AudioDevice {
    public enum Type {
        MICROPHONE("麦克风"),
        SPEAKER("扬声器"),
        USB_AUDIO("USB音频设备"),
        BLUETOOTH("蓝牙音频设备");

        private final String displayName;

        Type(String displayName) {
            this.displayName = displayName;
        }

        public String getDisplayName() {
            return displayName;
        }
    }

    private String id;
    private String name;
    private Type type;
    private boolean available;


    private boolean muted;
    private boolean muteSupported;
    private float volume;
    private float originalVolume;

    public AudioDevice(String id, String name, Type type, boolean available) {
        this.id = id;
        this.name = name;
        this.type = type;
        this.available = available;

        this.muteSupported = true;
        this.volume = 1.0f;
        this.originalVolume = 1.0f;
    }

    // Getters
    public String getId() { return id; }
    public String getName() { return name; }
    public Type getType() { return type; }
    public boolean isAvailable() { return available; }

    public boolean isMuted() { return muted; }
    public void setMuted(boolean muted) { this.muted = muted; }

    public boolean isMuteSupported() { return muteSupported; }
    public void setMuteSupported(boolean muteSupported) { this.muteSupported = muteSupported; }

    public float getVolume() { return volume; }
    public void setVolume(float volume) {
        this.volume = Math.max(0.0f, Math.min(1.0f, volume));
    }

    public float getOriginalVolume() { return originalVolume; }
    public void setOriginalVolume(float originalVolume) { this.originalVolume = originalVolume; }

    // Setters
    public void setAvailable(boolean available) { this.available = available; }

    @Override
    public String toString() {
        return "AudioDevice{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", type=" + type +
                ", available=" + available +
                ", muted=" + muted +
                ", muteSupported=" + muteSupported +
                ", volume=" + volume +
                '}';
    }
}
